<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Boost.Polygon's polygon_data</title>
<link rel="stylesheet" href="../../../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../../../../index.html" title="Chapter 1. Geometry">
<link rel="up" href="../boost_polygon.html" title="Boost.Polygon">
<link rel="prev" href="rectangle_data.html" title="Boost.Polygon's rectangle_data">
<link rel="next" href="polygon_with_holes_data.html" title="Boost.Polygon's polygon_with_holes_data">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="rectangle_data.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../boost_polygon.html"><img src="../../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../../index.html"><img src="../../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="polygon_with_holes_data.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h5 class="title">
<a name="geometry.reference.adapted.boost_polygon.polygon_data"></a><a class="link" href="polygon_data.html" title="Boost.Polygon's polygon_data">Boost.Polygon's
          polygon_data</a>
</h5></div></div></div>
<p>
            Boost.Polygon's polygon type (boost::polygon::polygon_data) is adapted
            to the Boost.Geometry Ring Concept.
          </p>
<h6>
<a name="geometry.reference.adapted.boost_polygon.polygon_data.h0"></a>
            <span class="phrase"><a name="geometry.reference.adapted.boost_polygon.polygon_data.description"></a></span><a class="link" href="polygon_data.html#geometry.reference.adapted.boost_polygon.polygon_data.description">Description</a>
          </h6>
<p>
            Boost.Polygon's points (as well as polygons) can be used by Boost.Geometry.
            The two libraries can therefore be used together. Using a boost::polygon::polygon_data&lt;...&gt;,
            algorithms from both Boost.Polygon and Boost.Geometry can be called.
          </p>
<h6>
<a name="geometry.reference.adapted.boost_polygon.polygon_data.h1"></a>
            <span class="phrase"><a name="geometry.reference.adapted.boost_polygon.polygon_data.model_of"></a></span><a class="link" href="polygon_data.html#geometry.reference.adapted.boost_polygon.polygon_data.model_of">Model
            of</a>
          </h6>
<p>
            <a class="link" href="../../concepts/concept_ring.html" title="Ring Concept">Ring Concept</a>
          </p>
<h6>
<a name="geometry.reference.adapted.boost_polygon.polygon_data.h2"></a>
            <span class="phrase"><a name="geometry.reference.adapted.boost_polygon.polygon_data.header"></a></span><a class="link" href="polygon_data.html#geometry.reference.adapted.boost_polygon.polygon_data.header">Header</a>
          </h6>
<p>
            <code class="computeroutput"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">geometry</span><span class="special">/</span><span class="identifier">geometries</span><span class="special">/</span><span class="identifier">adapted</span><span class="special">/</span><span class="identifier">boost_polygon</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span></code>
          </p>
<p>
            The standard header <code class="computeroutput"><span class="identifier">boost</span><span class="special">/</span><span class="identifier">geometry</span><span class="special">.</span><span class="identifier">hpp</span></code>
            does not include this header.
          </p>
<h6>
<a name="geometry.reference.adapted.boost_polygon.polygon_data.h3"></a>
            <span class="phrase"><a name="geometry.reference.adapted.boost_polygon.polygon_data.example"></a></span><a class="link" href="polygon_data.html#geometry.reference.adapted.boost_polygon.polygon_data.example">Example</a>
          </h6>
<p>
            Shows how to use Boost.Polygon polygon_data within Boost.Geometry
          </p>
<p>
</p>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">iostream</span><span class="special">&gt;</span>
<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">geometry</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">geometry</span><span class="special">/</span><span class="identifier">geometries</span><span class="special">/</span><span class="identifier">adapted</span><span class="special">/</span><span class="identifier">boost_polygon</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>

<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span>
<span class="special">{</span>
    <span class="keyword">typedef</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">polygon</span><span class="special">::</span><span class="identifier">polygon_data</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">&gt;</span> <span class="identifier">polygon</span><span class="special">;</span>
    <span class="keyword">typedef</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">polygon</span><span class="special">::</span><span class="identifier">polygon_traits</span><span class="special">&lt;</span><span class="identifier">polygon</span><span class="special">&gt;::</span><span class="identifier">point_type</span> <span class="identifier">point</span><span class="special">;</span>

    <span class="identifier">point</span> <span class="identifier">pts</span><span class="special">[</span><span class="number">5</span><span class="special">]</span> <span class="special">=</span> <span class="special">{</span>
        <span class="identifier">boost</span><span class="special">::</span><span class="identifier">polygon</span><span class="special">::</span><span class="identifier">construct</span><span class="special">&lt;</span><span class="identifier">point</span><span class="special">&gt;(</span><span class="number">0</span><span class="special">,</span> <span class="number">0</span><span class="special">),</span>
        <span class="identifier">boost</span><span class="special">::</span><span class="identifier">polygon</span><span class="special">::</span><span class="identifier">construct</span><span class="special">&lt;</span><span class="identifier">point</span><span class="special">&gt;(</span><span class="number">0</span><span class="special">,</span> <span class="number">10</span><span class="special">),</span>
        <span class="identifier">boost</span><span class="special">::</span><span class="identifier">polygon</span><span class="special">::</span><span class="identifier">construct</span><span class="special">&lt;</span><span class="identifier">point</span><span class="special">&gt;(</span><span class="number">10</span><span class="special">,</span> <span class="number">10</span><span class="special">),</span>
        <span class="identifier">boost</span><span class="special">::</span><span class="identifier">polygon</span><span class="special">::</span><span class="identifier">construct</span><span class="special">&lt;</span><span class="identifier">point</span><span class="special">&gt;(</span><span class="number">10</span><span class="special">,</span> <span class="number">0</span><span class="special">),</span>
        <span class="identifier">boost</span><span class="special">::</span><span class="identifier">polygon</span><span class="special">::</span><span class="identifier">construct</span><span class="special">&lt;</span><span class="identifier">point</span><span class="special">&gt;(</span><span class="number">0</span><span class="special">,</span> <span class="number">0</span><span class="special">)</span>
    <span class="special">};</span>

    <span class="identifier">polygon</span> <span class="identifier">poly</span><span class="special">;</span>
    <span class="identifier">boost</span><span class="special">::</span><span class="identifier">polygon</span><span class="special">::</span><span class="identifier">set_points</span><span class="special">(</span><span class="identifier">poly</span><span class="special">,</span> <span class="identifier">pts</span><span class="special">,</span> <span class="identifier">pts</span><span class="special">+</span><span class="number">5</span><span class="special">);</span>

    <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"Area (using Boost.Geometry): "</span>
        <span class="special">&lt;&lt;</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">geometry</span><span class="special">::</span><span class="identifier">area</span><span class="special">(</span><span class="identifier">poly</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
    <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"Area (using Boost.Polygon): "</span>
        <span class="special">&lt;&lt;</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">polygon</span><span class="special">::</span><span class="identifier">area</span><span class="special">(</span><span class="identifier">poly</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>

    <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span>
<span class="special">}</span>
</pre>
<p>
          </p>
<p>
            Output:
          </p>
<pre class="programlisting">Area (using Boost.Geometry): 100
Area (using Boost.Polygon): 100
</pre>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright © 2009-2021 Barend Gehrels,
      Bruno Lalande, Mateusz Loskot, Adam Wulkiewicz, Oracle and/or its affiliates<p>
        Distributed under the Boost Software License, Version 1.0. (See accompanying
        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
      </p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="rectangle_data.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../boost_polygon.html"><img src="../../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../../index.html"><img src="../../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="polygon_with_holes_data.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
